# !/usr/bin/env python
# -*-coding:utf-8 -*-

"""
# File       : task_node_schema.py
# Time       ：2024/9/8 23:07
# Author     ：Y-aong
# version    ：python 3.10
# Description：
"""
from marshmallow import fields
from marshmallow_sqlalchemy import SQLAlchemyAutoSchema

from orderlines.utils.utils import get_variable_value


class ProcessVariableSchema(SQLAlchemyAutoSchema):
    id = fields.Integer()
    process_name = fields.String()
    variable_key = fields.String()
    variable_value = fields.Function(
        serialize=lambda obj: get_variable_value(obj.variable_value, obj.variable_type)
    )
    variable_type = fields.String()
    variable_desc = fields.String()
